package com.yzh.book.service;

import com.yzh.book.dao.BookDao;
import com.yzh.book.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Component
public class BookService {
    //    数据库的东西放在service里面

    @Autowired
    BookDao bookDao;

    public List<BookInfo> getBookList() {
        List<BookInfo> bookInfos = bookDao.mockData();
        for (BookInfo bookInfo : bookInfos) {
            if (bookInfo.getState() == 2) {
                bookInfo.setStatusCN("不可借阅");
            } else {
                bookInfo.setStatusCN("可借阅");
            }
        }
        return bookInfos;
    }
}
